package info.thereisonlywe.onenesspathfinder.ui;

import java.awt.Dimension;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

import javax.swing.JSplitPane;

public class QuranBrowserView extends JSplitPane {

	private VersePane pane_Verse;

	private SectionPane pane_Section;

	public QuranBrowserView()
	{
		super();
		setOneTouchExpandable(true);
		setRightComponent(getVersePane());
		setLeftComponent(getSectionPane());
		getLeftComponent().setMinimumSize(new Dimension());
		getRightComponent().setMinimumSize(new Dimension());
		setDividerSize(5);
		setResizeWeight(0);
		setDividerLocation(200);
		setOrientation(JSplitPane.VERTICAL_SPLIT);
		addPropertyChangeListener(new PropertyChangeListener()
		{

			@Override
			public void propertyChange(PropertyChangeEvent evt)
			{
				if (evt.getPropertyName().equals(
						JSplitPane.DIVIDER_LOCATION_PROPERTY))
				{
					UIDelegate.SectionPaneHook.focusRow(UIDelegate
							.getDisplayedVerse().getVerseNumber() - 1);
				}
			}
		});
	}

	protected VersePane getVersePane()
	{
		if (pane_Verse == null)
		{
			pane_Verse = new VersePane();
		}
		return pane_Verse;
	}

	protected SectionPane getSectionPane()
	{
		if (pane_Section == null)
		{
			pane_Section = new SectionPane();
		}
		return pane_Section;
	}

}
